Controlling an interactive Theme
Themes have the primary API calls Load()
, Start()
, and Stop()
. To control themes interactively, the majority of functionality can be achieved using the SetControl function. While everything can be controlled using this function, it is dependent on how the theme has been created and set up.
Theme.SetControl
Below is an example of how you could set a parameter called progress
based on the distance between the Player and the Boss. This could potentially increase the tempo and density of the music, transitioning from a happy harmony to something more dissonant and ominous.
public class SetControlByDistance : MonoBehaviour
{
public Transform Player;
public Transform Boss;
public string ControlName = "progress"
void Update()
{
var distance = Vector3.Distance(Player.position, Boss.position);
var normalizedValue = Mathf.InverseLerp(300, 0, distance);
Reactional.Playback.Theme.SetControl(ControlName, normalizedValue);
}
}
Theme.TriggerStinger
While stingers can be scheduled to play at certain positions on a parameter using SetControl
, a more direct method is to call them directly. The code below will randomly play a stinger from the “ActionStinger” category, provided that one exists in the project.
Reactional.Playback.Theme.TriggerStinger("ActionStinger");
Theme.TriggerState
States can be considered snapshots of the musical settings and macro controls, set up by the composer They can transition the theme between musical sections or modify multiple settings simultaneously.
Reactional.Playback.Theme.TriggerState("Part A");